package com.ruoyi.business.config;

import com.ruoyi.business.interceptor.SignInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
public class DefaultMvcConfig implements WebMvcConfigurer {
    @Resource
    private SignInterceptor signInterceptor;

    /**
     * 手动拦截指定接口请求
     *
     * @param registry
     * @return void
     * @author JerryLu
     * @date 2024/8/22 9:42
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //所有请求都需要进行报文签名sign
        registry.addInterceptor(signInterceptor).addPathPatterns("/api/weight/*");
    }
}
